home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / VideoToolboxSources / ffprintf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-23  |  949 b   |  38 lines  |  [TEXT/MMCC]

  1. /*
  2. ffprintf.c
  3. ffprintf(o,format,...);
  4. Uses fprintf to print to two output streams, o[0] and o[1], usually stdout and a file. 
  5. Any NULL stream is ignored.
  6. It also saves and restores the port and GDevice.
  7. Copyright (c) 1990 Denis G. Pelli
  8. HISTORY:
  9. 9/14/90    dgp    wrote it, based on my UserPrintf(), which it replaces
  10. 8/27/92    dgp    check for 8-bit quickdraw before using GDevices.
  11. */
  12. #include "VideoToolbox.h"
  13. #include <stdarg.h>      /* for variable-number-of-argument macros */
  14.  
  15. int ffprintf(FILE *stream[2],char *format,...)
  16. {
  17.     va_list args;
  18.     int i,j;
  19.     GDHandle oldDevice;
  20.     long qD=0;
  21.   
  22.     Gestalt(gestaltQuickdrawVersion,&qD);
  23.     if(qD>=gestalt8BitQD){
  24.         oldDevice = GetGDevice();
  25.         SetGDevice(GetMainDevice());
  26.     }
  27.     
  28.     /* print copies to all non-NULL streams in stream[] */
  29.     for(i=0;i<2; i++){
  30.         va_start(args, format);
  31.         if(stream[i] != NULL) j=vfprintf(stream[i],format,args);
  32.     }
  33.     va_end(args);
  34.     
  35.     if(qD>=gestalt8BitQD)SetGDevice(oldDevice);
  36.     return j;
  37. }
  38.